class Solution {
public:
    int takeAttendance(vector<int>& records) 
    {
        int n=records.size();
        int left=0,right=n-1,ans=-1;
        while(left<=right)
        {
            int mid=(right-left)/2+left;
            if(records[mid]==mid)
            {
                left=mid+1;
            }
            else
            {
                ans=mid;
                right=mid-1;
            }
        }
        if(ans==-1) ans=left;//防止二分查找到最右边还没有找到 就比如【0 1 2 3 4】缺少5
        return ans;

    }
};